package com.chenhao.springcloud.chenhaodesignservice.pattern.creational.singleton;

/**
 * Description:threadLocal单例模式
 *
 * @author chenhao
 * @date 2020/12/21 10:45
 */
public class ThreadLocalInstance {
    private  static final ThreadLocal<ThreadLocalInstance> threadLocalInstanceThreadLocal
            = new ThreadLocal <ThreadLocalInstance>() {
                @Override
                protected ThreadLocalInstance initialValue() {
                    return new ThreadLocalInstance();
                }
            };
    private ThreadLocalInstance(){

    }

    public static ThreadLocalInstance getInstance(){
        return threadLocalInstanceThreadLocal.get();
    }
}
